from flask import g
from cache.user import UserStatusCache
# 判断用户是否登陆的装饰器
def loginrequired(func):

    def wrapper(*args, **kwargs):
        user_id = g.user_id
        if user_id is None:
            return {'message':'please login'}, 401
        elif g.is_refresh_token:
            return {'message':'你这个refresh token有毛病'}, 403
        else:
            return func(*args, **kwargs)

    return wrapper